package com.xr.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.core.env.Environment;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Date;

/**
 * @RestController类里所有方法都返回JSON数据
 */
@RestController
public class HelloController {

    @Value("${v_boolean}")
    private boolean v_boolean;
    @Value("${v_float}")
    private float v_float;
    @Value("${v_int}")
    private int v_int;
    @Value("${v_null}")
    private String v_null;
    @Value("${v_string}")
    private String v_string;
    @Value("${v_string2}")
    private String v_string2;
    @Value("${v_date}")
    private Date v_date;

    @Value("${student.name}")
    private String name;

    @Autowired
    private Environment environment;

    @RequestMapping("hello")
    public String hello(){
//        System.out.println(v_boolean);
        System.out.println(v_float);
        System.out.println(v_int);
        System.out.println(v_null);
        System.out.println(v_string);
        System.out.println(v_string2);
        System.out.println(v_date);
        System.out.println(name);

        System.out.println(environment.getProperty("v_boolean"));



        return "hello world";
    }

}
